#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

class unionset {
	vector<int> &father;
	vector<int> &value;
	vector<int> &price;

    public:
        unionset(vector<int> &f, vector<int> &v, vector<int> &p) : father(f), value(v), price(p)
        {
                iota(father.begin(), father.end(), 0);
        }

        int find(int x)
        {
                return father[x] == x ? x : father[x] = find(father[x]);
        }

        int merge(int x, int y)
        {
                int fx = find(x);
                int fy = find(y);
                if(fx != fy){
                        father[fx] = fy;
                        value[fy] += value[fx];
                        price[fy] += price[fx];
                        return fy;
                }
                return 0;
        }
};

int main()
{
	int n = 0, m = 0, w = 0;
	cin >> n >> m >> w;

        vector<int> father(n + 1, 0);
	vector<int> value(n + 1, 0);
	vector<int> price(n + 1, 0);
	for (int i = 1, c = 0, d = 0; i <= n; i++) {
		cin >> c >> d;
		value[i] = d;
		price[i] = c;
	}

        unionset uset(father, value, price);
	for (int i = 0, c1, c2; i < m; i++) {
                cin >> c1 >> c2;
                uset.merge(c1, c2);
	}

        vector<int> v(1, 0);
        vector<int> p(1, 0);
        for(int i = 1; i <= n; i++){
                if(father[i] == i){
                        v.push_back(value[i]);
                        p.push_back(price[i]);
                }
        }

        vector<int> dp(w + 1, 0);
        for(int i = 1; i < v.size(); i++){
                for(int j = w; j >= p[i]; j--){
                        dp[j] = max(dp[j], dp[j - p[i]] + v[i]);
                }
        }
        cout<<dp.back()<<endl;
        return 0;
}